import { createStore } from "vuex";

const store = createStore({
  state() {
    return {
      money: 10000,
    };
  },
  mutations: {
    addMoney(state) {
      state.money += 1000;
    },
    addMoneyPayload(state, payload) {
      state.money += payload;
    },
  },
  actions: {
    addMoneyAsync(context) {
      setTimeout(() => {
        context.commit("addMoney");
      }, 2000);
    },
  },
  getters: {
    double(state) {
      return state.money * 2;
    },
  },
});

export default store;
